library("magrittr")
library("png")
library("imager")
library("dplyr")
library("tidyr")
library("ggplot2")
library("jpeg")
library("grid")
library("plotly")
library("brocks")
setwd("/Users/davidizquierdogomez/Desktop/schemalegende")
x <- c(6,2,3,4,5,6,7,8,9,10,11,12,9)
y <- c(9,1,5,3,6,7,9,5,3,10,11,11,8)
n <- c("noyau", "cytoplasme", "ribosome", "nucléole", "ADN", "ARNm", "mitochondrie", "MP", "envelope_nucleaire", "Golgi", "RER", "REL", "lisosome")
data <- cbind(x, y, n) %>%
as_tibble() %>%
mutate(x = as.numeric(x)) %>%
mutate(y = as.numeric(y))
data
## # A tibble: 13 x 3
## x y n
## <dbl> <dbl> <chr>
## 1 6 9 noyau
## 2 2 1 cytoplasme
## 3 3 5 ribosome
## 4 4 3 nucléole
## 5 5 6 ADN
## 6 6 7 ARNm
## 7 7 9 mitochondrie
## 8 8 5 MP
## 9 9 3 envelope_nucleaire
## 10 10 10 Golgi
## 11 11 11 RER
## 12 12 11 REL
## 13 9 8 lisosome
img <- load.image("cellschema.png")
plot <- ggplot(data,aes(x = x,y = y)) +
geom_point(size = 0.01) +
annotation_custom(rasterGrob(img, width=unit(1,"npc"), height=unit(1,"npc")),
-Inf, Inf, -Inf, Inf) +
scale_y_continuous(expand = c(0,0), limits = c(0, max(y)*1.05)) +
# geom_text(aes(label = n), vjust = 1.5, colour = "black") +
theme_bw() +
theme(plot.title = element_text(size = rel(1.5), face = "bold", vjust = 1.5),
axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank()) +
ggtitle("Cellule eucaryote") +
theme(title = element_text(size = 15, hjust = 0.5)) +
labs(x="David Izquierdo")
plot
Saving background image $ Setting font & Plotting
image_destination <- "https://raw.githubusercontent.com/davidizquierdogomez/pictures/main/photos/cellschema.png"
gg <- ggplot(data, aes(text = n)) +
geom_point(data = data, x = x, y = y, size = 1, colour = "red") +
scale_y_continuous(expand = c(0,0), limits = c(0, max(y))) +
scale_x_continuous(expand = c(0,0), limits = c(0, max(x))) +
# geom_text(aes(label = n), vjust = 1.5, colour = "black") +
theme_bw() +
theme(plot.title = element_text(size = rel(1.5), face = "bold", vjust = 1.5),
axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank()) +
ggtitle("Cellule eucaryote") +
theme(plot.title = element_text(size = 15, hjust = 0.5, colour = "red")) +
labs(x="David Izquierdo")
pp <- ggplotly(gg, width = 700, height = 575) %>%
config(displayModeBar = F)
plotly::layout(pp,
xaxis = list(showgrid = F),
yaxis = list(showgrid = F),
images = list(
list(
source = image_destination,
xref = "x",
yref = "y",
x = -1,
y = 13,
sizex = 14,
sizey = 13,
sizing = "stretch",
opacity = 0.9,
layer = "below"
)
))